*FD graphs
*
use temp1,clear
*
global inityear = 1996
keep if year == $inityear
collapse (sum)  totalexport = totexport, by(firmid)
gsort -totalexport
gen cumexport = sum(totalexport)
gen cumshrexport =  cumexport/cumexport[_N]
keep if cumshrexport < .5001
global nfirms = _N
keep firmid
sort firmid
save temptop1000, replace
*
use temp1,clear
sort firmid
merge firmid using temptop1000
tab _merge
keep if _merge == 3
drop if year == 1995
*
global depvar_d1  "llaborpty_d1"
*
*Trimming
drop p1_pty p99_pty
egen p1_pty=pctile($depvar_d1),p(1)
egen p99_pty=pctile($depvar_d1),p(99)
replace $depvar_d1 =. if ($depvar_d1>p99_pty | $depvar_d1 <p1_pty) & $depvar_d1!=.
egen p1_shock=pctile(shock6intens),p(1)
egen p99_shock=pctile(shock6intens),p(99)
replace shock6intens =. if (shock6intens>p99_shock| shock6intens<p1_shock) & shock6intens!=.
*
label var $depvar_d1 " change in log labor productivity"
label var shock6intens " change in log trade shock"
*
reg $depvar_d1  shock6intens, robust cluster(firmid)
global beta = round(_b[shock6intens],.001)
global se = round(_se[shock6intens],.001)
global t = round($beta/$se, .001)
global nfirms2 = e(N)
*
scatter $depvar_d1  shock6intens, scheme(mys2color) ///
ytitle(" change in log labor productivity") msymbol(oh) ///
|| lfit $depvar_d1  shock6intens , legend(off) ///
xlab(-.2(0.1).2) ylab(-1.5(0.5)1.) xsize(3) ysize(3)     ///
note("regression line: coef =  $beta, se =  $se, N = $nfirms2" "sample: $nfirms firms representing 50% of French exports in 1996" "standard errors clustered by firm")
*
graph export $DIRLOG/Replication/graph_introFD.pdf, as(pdf) replace
*
reg $depvar_d1  shock6intens linv_d1 lmatraw_d1 yd*, robust cluster(firmid)
global beta = string(round(_b[shock6intens],0.001))
global se = string(round(_se[shock6intens],.001))
global t = string(round($beta/$se,.001))
global nfirms2 = e(N)
avplot shock6intens, msymbol(oh) scheme(mys2color) ytitle(" cond. change in ln labour productivity") xtitle("cond. change in ln trade shock")  ///
xlab(-.2(0.1).2) ylab(-1.5(0.5)1) xsize(3) ysize(3)  ///
note("regression line: coef =  $beta, se =  $se, N = $nfirms2" "sample: $nfirms firms representing 50% of French exports in 1996" "standard errors clustered by firm")
*
graph export $DIRLOG/Replication/graph_intro_avplotFD.pdf, as(pdf) replace


